// Josh made this
#include "TextureMap.h"

map<string, Texture*> TT::TextureLibrary;

char *arrayText[] =
{
	"images/Boulder.png",				// Slot 0,
	"images/jungleBackGround.png",		// Slot 1,
	"images/log.png",					// Slot 2,
	"images/Caveman_SpriteSheet.png",   // Slot 3,
	"images/tiger.png",					// Slot 4,
	"images/main_menu_caveman.png",		// Slot 5,
};

int arrayCount = sizeof(arrayText) / sizeof(arrayText[0]);

void TT::FreeTexture(const std::string &s)
{
	// Find the texture from our library and delete it.
	delete TT::TextureLibrary[s];
	// Remove that enrty from our library
	TT::TextureLibrary.erase(s);
}

void TT::LoadTexture(const std::string &s)
{
	using namespace sf;
	using namespace std;

	if (TT::TextureLibrary.find(s) != TT::TextureLibrary.end())
	{
		// We found the texture already in the library.
		// Return withoout loading it.
		return;
	}

	// Creating a new txture
	Texture *texture = new Texture;
	// Loading the texture from the file.
	texture->loadFromFile(s);
	// Register this texture with our Texture Library
	TT::TextureLibrary[s] = texture;
}